{extend name="public/base"}
{block name='main'}

<!--编辑菜单-->
<form class="layui-form layui-form-pane" action="" style="padding:20px;">
  <input type="hidden" name="id" value="{$info.id|default=''}" />
  <div class="layui-form-item">
    <label class="layui-form-label">文件上传</label>
    <div class="layui-input-block">
      <button type="button" class="layui-btn" id="firstID">
        <i class="layui-icon">&#xe67c;</i>上传按钮
      </button>
      <input type="hidden" name="convert_status" id="convert_status" class="layui-input" value="{$info.convert_status|default='1'}">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">文档标题</label>
    <div class="layui-input-block">
      <input type="text" name="title" id="title" placeholder="请输入" class="layui-input" value="{$info.title|default=''}">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">文档分类</label>
    <div class="layui-input-block">
      <select name="cid" lay-verify=“required|number”>
        <option value=""></option>
        {volist name="catelist" id="val" }
          <option disabled="disabled" value="{$val.id}" {eq name="$info.cid|default=''" value="$val.id"}selected="selected"{/eq}>{$val.name}</option>
        {volist name="val['erji']" id="vo"}
            <option value="{$vo.id}" {eq name="$info.cid|default=''" value="$vo.id"}selected="selected"{/eq}>&nbsp;&nbsp;&nbsp;├─ {$vo.name}</option>
        {/volist}
        {/volist}
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">文档专辑</label>
    <div class="layui-input-block">
      <select name="zjid" >
        <option value=""></option>
        {volist name="zjlist" id="val" }
          <option value="{$val.id}" {eq name="$info.zjid|default=''" value="$val.id"}selected="selected"{/eq}>{$val.title}</option>
        {/volist}
      </select>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">文档简介</label>
    <div class="layui-input-block">
      <textarea name="intro" id="intro" class="layui-textarea">{$info.intro|default=''}</textarea>
    </div>
  </div>

  <div class="layui-form-item" >
    <label class="layui-form-label" >文档积分</label>
    <div class="layui-input-block">
      <input type="number" name="score" id="score" class="layui-input" value="{$info.score|default='0'}">
    </div>
  </div>

  <div class="layui-form-item" >
    <label class="layui-form-label">状态</label>
    <div class="layui-input-block">
      <input type="radio" title="未审核" name="status" value="0" {eq name="$info.status|default='0'" value="0"}checked="checked"{/eq}>
      <input type="radio" title="已审核" name="status" value="1" {eq name="$info.status|default=''" value="1"}checked="checked"{/eq}>


    </div>
  </div>
  <div class="layui-form-item" >
    <label class="layui-form-label">精品推荐</label>
    <div class="layui-input-block">
      <input type="radio" title="是" name="choice" value="1" {eq name="$info.choice|default='1'" value="1"}checked="checked"{/eq}>
      <input type="radio" title="否" name="choice" value="0" {eq name="$info.choice|default='0'" value="0"}checked="checked"{/eq}>
    </div>
  </div>
  <div class="layui-form-item" >
    <label class="layui-form-label">置顶</label>
    <div class="layui-input-block">
      <input type="radio" title="是" name="top" value="1" {eq name="$info.top|default='1'" value="1"}checked="checked"{/eq}>
      <input type="radio" title="否" name="top" value="0" {eq name="$info.top|default='0'" value="0"}checked="checked"{/eq}>
    </div>
  </div>
  <input type="hidden" name="fileurl"  id="fileurl"  size="30" value="{$info.fileurl|default=''}">
  <input type="hidden" name="ext"  id="ext"  size="30" value="{$info.ext|default=''}">
  <input type="hidden" name="filesize"  id="filesize"  size="30" value="{$info.filesize|default=''}">
  <input type="hidden" name="oldname"  id="oldname"  size="30" value="{$info.oldname|default=''}">
  <input type="hidden" name="hash"  id="hash"  size="30" value="{$info.hash|default=''}">
  <input type="hidden" name="viewurl"  id="viewurl"  size="30" value="{$info.viewurl|default=''}">
  <input type="hidden" name="convert_key"  id="convert_key"  size="30" value="{$info.convert_key|default=''}">
  <input type="hidden" name="tags" id="tags"  value="{$info.tags|default=''}" >

  <div class="layui-form-item">
    <label class=""></label>
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="content_edit">提交保存</button>
    </div>
  </div>
</form>



<script>
  //Demo
  layui.use(['layer','jquery','form','element','upload'], function () {
    // 操作对象
    var layer = layui.layer,$ = layui.jquery,form = layui.form, element = layui.element,upload = layui.upload;

    // 提交
    Oper.initUpdate(layui, '文档分类', 'content_edit', 'doc_con/edit');

    //上传图片
    upload.render({
      elem: '#firstID', 			//选中你要绑定的上传组件
      url: "{:url('doc_con/ajax_upload')}",//上传接口
      accept:'file',					//文件类型，不写默认是images，file表示全类型
      done: function(data){		//上传完回调，这里的res必须是json类型
        if (data.status === 1) {
          layer.msg(data.msg, {icon: 1});
          $('#fileurl').val(data.info.name);
          $('#oldname').val(data.info.oldname);
          $('#title').val(data.info.oldname);
          $('#filesize').val(data.info.size);
          $('#viewurl').val(data.info.name);
          $('#hash').val(data.info.hash);
          $('#tags').val(data.info.ext);
          $('#ext').val(data.info.ext);
          $('#convert_key').val(data.info.convert_key);
        }else{
          layer.msg('上传失败', {icon: 2});
        }
      },
      error: function(){
        layer.msg('error'+ res.status, {icon: 2});
      }
    });
  });
</script>
{/block}